package com.yl.module.property.controller;

import com.yl.common.core.validate.Group;
import com.yl.module.file.domain.FileType;
import com.yl.module.file.domain.vo.File2VO;
import com.yl.module.file.service.FileService;
import com.yl.module.property.domain.dto.PropertyUpkeepAddOrUpdDTO;
import com.yl.module.property.domain.vo.PropertyMaintainVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import lombok.extern.slf4j.Slf4j;
import io.swagger.annotations.Api;
import com.yl.module.property.service.PropertyUpkeepService;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import com.yl.module.property.domain.PropertyUpkeep;
import com.yl.module.property.domain.vo.PropertyUpkeepVO;
import com.yl.module.property.domain.dto.PropertyUpkeepDTO;
import com.yl.common.core.domain.Result;
import javax.validation.constraints.NotNull;
import java.util.List;
import javax.validation.constraints.NotEmpty;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.multipart.MultipartFile;

/**
 * 资产维修记录表 Controller控制层
 * @author makejava
 * @date 2024-10-23 15:54:16
 */
@Slf4j
@RestController
@Api(tags = "资产维修记录")
@RequestMapping("/propertyUpkeep")
@Validated
public class PropertyUpkeepController {
    /**
     * 资产维修记录表 Service
     */
    @Autowired
    public PropertyUpkeepService propertyUpkeepService;
	@Autowired
	public FileService fileService;

	@PostMapping("file")
	@ApiOperation(value = "资产维修文件上传", notes = "")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "file", value = "文件", required = true, dataType = "MultipartFile"),
	})
	public Result<File2VO> file(
			@RequestParam(name = "file") MultipartFile file
	) {
		File2VO result = fileService.upload(FileType.TypeEnum.FILE_TYPE_1002.getCode(),file);
		return Result.ok(result);
	}

	@PostMapping("/add")
    @ApiOperation(value = "添加", notes = "")
	public Result<Long> add(
			@RequestBody @Validated(Group.Add.class) PropertyUpkeepAddOrUpdDTO dto
	) {
		Long result = propertyUpkeepService.add(dto);
		return Result.ok(result);
	}

	@PostMapping("/upd")
    @ApiOperation(value = "通过主键修改", notes = "")
	public Result upd(
		@RequestBody@Validated(Group.Upd.class) PropertyUpkeepAddOrUpdDTO dto
	) {
		propertyUpkeepService.upd(dto);
		return Result.ok();
	}

	@PostMapping("/del/{id}")
	@ApiOperation(value = "通过id逻辑删除", notes = "")
	public Result del(
			@PathVariable Long id
	) {
		propertyUpkeepService.del(id);
		return Result.ok();
	}

}

